package com.bai.api.service;

import com.bai.api.common.PageableEntity;
import com.bai.api.dao.ArticleDao;
import com.bai.api.entity.Article;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class ArticleService {

    @Resource
    ArticleDao dao;

    public Article findById(Article article) {

        return dao.findById(article.getId()).get();
    }

    public List<Article> findList(Article article){

        //PageableEntity page = new PageableEntity(article);
        return dao.findAll();
    }

    public List<Article> findByTitle(Article article){

        return dao.findByTitleLike("%" + article.getTitle() + "%");
    }

    public Article save(Article article){
        return dao.save(article);
    }

    public void delete(Article article){
        dao.delete(article);
    }


}
